<?php
require_once 'lib/config.php';
require_once 'lib/functions.php';

if ($_POST) {
    $nickname = isset($_POST['nickname'])?htmlentities($_POST['nickname'],ENT_QUOTES):'匿名';
    $content = isset($_POST['content'])?htmlentities($_POST['content'],ENT_QUOTES):'';
    $ip = $_SERVER['REMOTE_ADDR'];
    $t = time();
    if ($content=='') {
		msg('留言内容不能为空');
    } else {
        if ($db->query("INSERT INTO `guestbook` (`id`, `nickname`, `content`, `reply`,`t`, `ip`) VALUES (NULL, '{$nickname}', '{$content}', '','{$t}', '{$ip}');")) {
			msg('留言成功','index.php');
        } else {
			msg('系统错误');
        }
    }
}

require_once 'template/'.TPL.'/'.basename(__FILE__);
